package top.kaoshanji.p2ch15b;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 代码清单-p2ch15b-462页b：集合点协作示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/24 18:36
 */
public class AssemblePointDemo {

    private static final Logger logger = LogManager.getLogger(AssemblePointDemo.class);

    public static void main(String[] args) {
        logger.info("...start...");

        int num = 10;

        // 协作的共享变量：每个线程都会被阻塞和唤醒
        AssemblePoint ap = new AssemblePoint(num);

        AssemblePointThread[] threads = new AssemblePointThread[num];
        for (int i = 0; i < num; i++) {
            threads[i] = new AssemblePointThread(ap);
            threads[i].start();
        }

        logger.info("...end...");
    }
}
